package com.cskaoyan.shopping.controller.zhu;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 小朱
 * @Description:商品模块第三第四接口
 * @date: 16:32 2022/12/4
 */
@RestController
public class ShoppingController4 {
    @Autowired
    IProductService productService;

    @RequestMapping("shopping/product/{id}")
    public ResponseData showProduct (@PathVariable("id") Long id){
        ProductDetailDto productDetail = productService.getProductDetail(id);
        ResponseData<Object> responseData = new ResponseUtil<>().setData(productDetail);
        return responseData;
    }

    @RequestMapping("shopping/goods")
    public ResponseData showGoods(PageRequest request){
        AllProductResponse allProduct = productService.getAllProduct(request);
        ResponseData<Object> responseData = new ResponseUtil<>().setData(allProduct);
        return responseData;
    }

}
